home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / glossmap_arb.vp < prev    next >
Text File  |  2003-02-20  |  2KB  |  69 lines

  1. !!ARBvp1.0
  2.  
  3. # Compute specular just the specular light for use in a separate gloss
  4. # mapping pass.  A separate pass is necessary when using texenv
  5. # combiners because they can't use the secondary color; therefore
  6. # this vertex program outputs the specular lighting term primary
  7. # color.
  8.  
  9. ATTRIB iPos          = vertex.position;
  10. ATTRIB iNormal       = vertex.normal;
  11. ATTRIB iTex0         = vertex.texcoord[0];
  12. PARAM  mvp[4]        = { state.matrix.mvp };
  13. PARAM  lightDir      = program.env[0];
  14. PARAM  eyePos        = program.env[1];
  15. PARAM  specExp       = program.env[4];
  16. PARAM  specular      = program.env[3];
  17. PARAM  zero          = 0;
  18. PARAM  one           = 1;
  19. OUTPUT oPos          = result.position;
  20. OUTPUT oColor        = result.color;
  21. OUTPUT oTex0         = result.texcoord[0];
  22.  
  23. TEMP   diffuseFactor;
  24. TEMP   eyeVec;
  25. TEMP   halfAngle;
  26. TEMP   dotProds;
  27.  
  28. # Transform the vertex by the modelview matrix
  29. DP4   oPos.x, mvp[0], iPos;
  30. DP4   oPos.y, mvp[1], iPos;
  31. DP4   oPos.z, mvp[2], iPos;
  32. DP4   oPos.w, mvp[3], iPos;
  33.  
  34. # Compute the diffuse light component
  35. DP3   diffuseFactor, iNormal, lightDir;
  36. # Clamp the diffuse component to zero
  37. MAX   diffuseFactor, diffuseFactor, zero;
  38.  
  39. # Get the vector from the eye to the vertex
  40. SUB   eyeVec, eyePos, iPos;
  41.  
  42. # Normalize it
  43. DP3   eyeVec.w, eyeVec, eyeVec;
  44. RSQ   eyeVec.w, eyeVec.w;
  45. MUL   eyeVec, eyeVec, eyeVec.w;
  46.  
  47. # Compute the half angle vector for specular lighting
  48. ADD   halfAngle, eyeVec, lightDir;
  49. DP3   halfAngle.w, halfAngle, halfAngle;
  50. RSQ   halfAngle.w, halfAngle.w;
  51. MUL   halfAngle, halfAngle, halfAngle.w;
  52.  
  53. # Set up the specular dot products vectors:
  54. #    dotProds = { diffuse factor, spec factor, 0, spec exponent }
  55. MOV   dotProds.x, diffuseFactor.x;
  56. DP3   dotProds.y, halfAngle, iNormal;
  57. MAX   dotProds.y, dotProds.y, zero;
  58. MOV   dotProds.w, specExp.w;
  59.  
  60. # Output the texture
  61. MOV   oTex0, iTex0;
  62.  
  63. # Compute and output the specular color
  64. LIT   dotProds, dotProds;
  65. MUL   oColor, specular, dotProds.z;
  66.  
  67. END
  68.  
  69.